# to attach leaflet dependencies we do an invisible map
# otherwise procedural leaflets wont render
# https://stackoverflow.com/questions/63534247/recommended-way-to-initialize-js-renderer-in-asis-r-markdown-chunk
leaflet::leaflet(width = 0, height = 0)

Overall Performance

sli_performance%>%
  select(-raw_comparison) %>%
  DT::datatable()

Absolute Performance Plots

for (i in 1:nrow(sli_performance)){
  
  cat(sprintf("\n\n## %s\n\n", sli_performance$method[[i]]))
  
  print(plot_sli_performance(sli_performance$raw_comparison[[i]], 
                             title = sprintf("%s: Absolute performance", sli_performance$method[[i]]), 
                             plot_type = "absolute"))
}

SLI unoptimized

SLI mean absolute error

SLI mean absolute percentage error

SLI mean squared error

Absolute Performance Maps

for (i in 1:nrow(sli_performance)){
  
  cat(sprintf("\n\n## %s\n\n", sli_performance$method[[i]]))
  
  map <- leaflet_sli_performance(sli_performance$raw_comparison[[i]], ons_shp, "diff_count")
  
  cat(as.character(htmltools::tagList(map)))
}

SLI unoptimized

SLI mean absolute error

SLI mean absolute percentage error

SLI mean squared error

Relative Performance Plots

for (i in 1:nrow(sli_performance)){
  
  cat(sprintf("\n\n## %s\n\n", sli_performance$method[[i]]))
  
  print(plot_sli_performance(sli_performance$raw_comparison[[i]], 
                             title = sprintf("%s: Relative performance", sli_performance$method[[i]]), 
                             plot_type = "proportional"))
  
  print("\n\n")
  
  print(sli_performance$raw_comparison[[i]]$diff_prop %>% 
          abs() %>% 
          hist(main = paste0("Histogram of mean abs. pct. error, ", sli_performance$method[[i]])))
  
  print("\n\n")
  
  print(sli_performance$raw_comparison[[i]]$diff_prop %>%
          abs() %>%
          summary())
}

SLI unoptimized

[1] “” $breaks [1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0

$counts [1] 83 11 5 4 2 0 1 1 0 1

$density [1] 7.68518519 1.01851852 0.46296296 0.37037037 0.18518519 0.00000000 [7] 0.09259259 0.09259259 0.00000000 0.09259259

$mids [1] 0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85 0.95

$xname [1] “.”

$equidist [1] TRUE

attr(,“class”) [1] “histogram” [1] “” Min. 1st Qu. Median Mean 3rd Qu. Max. 0.000000 0.002648 0.014955 0.083289 0.080902 1.000000

SLI mean absolute error

## Warning: Removed 1 rows containing missing values (geom_point).

[1] “” $breaks [1] 0.0 0.2 0.4 0.6 0.8 1.0 1.2

$counts [1] 104 1 1 0 1 1

$density [1] 4.8148148 0.0462963 0.0462963 0.0000000 0.0462963 0.0462963

$mids [1] 0.1 0.3 0.5 0.7 0.9 1.1

$xname [1] “.”

$equidist [1] TRUE

attr(,“class”) [1] “histogram” [1] “” Min. 1st Qu. Median Mean 3rd Qu. Max. 0.000000 0.002538 0.012595 0.054304 0.041060 1.171429

SLI mean absolute percentage error

[1] “” $breaks [1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9

$counts [1] 96 8 1 1 1 0 0 0 1

$density [1] 8.88888889 0.74074074 0.09259259 0.09259259 0.09259259 0.00000000 0.00000000 [8] 0.00000000 0.09259259

$mids [1] 0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85

$xname [1] “.”

$equidist [1] TRUE

attr(,“class”) [1] “histogram” [1] “” Min. 1st Qu. Median Mean 3rd Qu. Max. 0.000000 0.002797 0.012908 0.046821 0.048937 0.882353

SLI mean squared error

[1] “” $breaks [1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9

$counts [1] 95 9 1 0 1 0 1 0 1

$density [1] 8.79629630 0.83333333 0.09259259 0.00000000 0.09259259 0.00000000 0.09259259 [8] 0.00000000 0.09259259

$mids [1] 0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85

$xname [1] “.”

$equidist [1] TRUE

attr(,“class”) [1] “histogram” [1] “” Min. 1st Qu. Median Mean 3rd Qu. Max. 0.000000 0.002538 0.011900 0.047541 0.034546 0.882353

Relative Performance Maps

for (i in 1:nrow(sli_performance)){
  
  cat(sprintf("\n\n## %s\n\n", sli_performance$method[[i]]))
  
  map <- leaflet_sli_performance(sli_performance$raw_comparison[[i]], ons_shp, "diff_prop")
  
  cat(as.character(htmltools::tagList(map)))
}

SLI unoptimized

SLI mean absolute error

SLI mean absolute percentage error

SLI mean squared error

3
## [1] 3